<#include 'member_header.html' />
<!--创建“订单详细”标签-->
<#assign orderDetailTag = newTag("orderDetailTag")>
<!--调用“订单详细”标签，并传递参数-->
<#assign orderDetail = orderDetailTag()>

<#--创建"支付列表"标签-->
<#assign shopPaymentListTag= newTag("shopPaymentListTag") >    
<#--调用"支付列表"标签-->          
<#assign paymentList = shopPaymentListTag()>

<#-- 获取订单状态标签 -->
<#assign orderStautsTag = newTag("orderStautsTag")>
<#-- 调用订单状态标签 -->
<#assign orderState = orderStautsTag()>  

	<div class="member-commen">
		<input type="hidden" value="${order_id}" id="order_id">
			<h1>售后方式<span>您可以对您商品进行退款或退货处理</span></h1>
			 <div class="member-comment-tab">
			 	<ul>
			 		<li class="mine-comment selected" type="1" style="border: none">退款申请</li>
			 		<#if orderDetail.ship_status != orderState.SHIP_NO  >
						<#if orderDetail.pay_status == orderState.PAY_YES  >
					<li class="mine-wait-comment" type="2">退货申请</li>
					</#if>
					</#if>
			 		
			 	</ul>
			 </div>
		<div class="member-comment-box">
		 	<div class="return_detail" id="type_1">
				<form id="returnForm" class="validate">
					<input type="hidden" name="orderid" value="${order_id}" />
					
					<h3>是否已收货</h3>
					<#if orderDetail.ship_status == orderState.SHIP_NO  >
						<input type="radio" value="0" name="ship_status" checked="checked"/>未收货
					</#if>
					<#if orderDetail.ship_status != orderState.SHIP_NO  >
						<#if orderDetail.pay_status == orderState.PAY_YES  >
						<input type="radio" value="1" name="ship_status" checked="checked"/>已收货
					</#if>
					</#if>
					<h3>退款方式</h3>
					<div class="return-way">
						<h4>退款方式：${orderDetail.payment_name}</h4>
						<h4>退款账户</h4>
						<input type="text" name="return_account" id="payment_account" class="return-way-name" maxlength="255" />
					</div>
					
					<h3>退款原因</h3>
					<div class="return-way">
						<select name="reason" id="ship_status0">
							<option value="0">请选择退款原因</option>
							<option value="买错/不想要">买错/不想要</option>
							<option value="未按照时间发货">未按照时间发货</option>
							<option value="快递一直没有收到">快递一直没有收到</option>
							<option value="快递无记录">快递无记录</option>
							<option value="其他">其他</option>
						</select>
						<select id="ship_status1" style="display: none;">
							<option value="0">请选择退货原因</option>
							<option value="商品质量有问题">商品质量有问题</option>
							<option value="收到商品与描述不符">收到商品与描述不符</option>
							<option value="不喜欢/不想要">不喜欢/不想要</option>
							<option value="发票问题">发票问题</option>
							<option value="空包裹">空包裹</option>
							<option value="其他">其他</option>
						</select>
					</div>
					<div>
						<h3>退款金额</h3>
						<div class="return-way">
							<input type="text" name="apply_alltotal" dataType="float" id="price" isrequired="true" maxlength="7" value="${orderDetail.paymoney!''}"/>
							<input type="hidden"  id="payprice" value="${orderDetail.paymoney!''}"/>
						</div>
					</div>
					<h3>问题描述</h3>
					<div class="return-word">
						<textarea name="remark" maxlength="100"   isrequired="true" class="return-word-detail"></textarea>
					</div>
					<div class="return-tools btn-div">
						<input type="button" name="btnSubmit" value="申请退款" id="btnSubmit" class="yellow-btn" />
					</div>
				</form>
			</div>
			<div class="return-goods" id="type_2" style="display: none;">

			</div>
		<!-- 退货申请 -->
		<div class="return" style="display:none;">
	 	</div>
	 	<em class="point-upward"></em>
	 </div>
	</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){

	$("input[name='ship_status']").click(function(){
		var status = $('input[name="ship_status"]:checked').val();
		var uncheckstatus = $('input[name="ship_status"]').not("input:checked").val();
		$("#ship_status"+uncheckstatus).removeAttr('name').hide();
		$("#ship_status"+status).attr('name', 'reason').show();
		if(status == 1){
			$('#btnSubmit').val('申请退货');
		}else {
			$('#btnSubmit').val('申请退款');
		};
	})

	$('.return-goods').empty().load("return.html?order_id="+$('#order_id').val());
	//选项卡切换
	$(".member-comment-tab ul li").click(function(){
		$(".point-upward").css("left","35px");
		var _this = $(this), type = _this.attr('type');
		_this.addClass('selected');
		_this.siblings('li').removeClass('selected');
		if(type == 1){
			$('#type_1').show();
			$('#type_2').hide();
            $('.point-upward').css({left: 35});
		}else {
			$('#type_1').hide();
			$('#type_2').show();
            $('.point-upward').css({left: 145});
		};
	})

	$("#btnSubmit").click(function(){
		var status = $('input[name="ship_status"]:checked').val();
		if($("#ship_status0").val()==0){
			alert("请选择退款原因");
			return false;
		}
		if(!$("#returnForm").checkall()){
			return false;
		}else if($('input[name="ship_status"]:checked').val()==null){
			alert("请选择是否收货");
			return false;
		}else if($("input[name='apply_alltotal']").val() < 0){
			alert('退款金额不能为负');
			return false;
		}else if(Number($("input[name='apply_alltotal']").val()) > Number($("#payprice").val())){
			alert('退款金额不能大于实付金额');
			return false;
		}else if($("input#payment_account").val() == ""){
			alert("退款账号不能为空");
			return false;
		}
		if($(".return-word-detail").val().length > 100){
			alert("问题描述不能超过100字");
			return false;
		}
		var options = {
			url : "${ctx}/api/shop/sell-back/return-money.do",
			type : "POST",
			dataType : 'json',
			success : function(result) {
				if(result.result==1){
					alert(result.message);
					location.href="return_list.html"
				}else{
					alert(result.message);
				}
			},
			error : function(e) {
				alert("出现错误 ，请重试");
			}
		};
		$('#returnForm').ajaxSubmit(options);
	});
	
});
	
</script>
<#include '../common/footer.html'/>